<template>
    <div class="audit-project-document-view">

      <el-table
        size="medium"
        :data="list"
        border
        style="width: 100%">
        <el-table-column
          align="center"
          prop="file_name"
          label="文档名称">
        </el-table-column>
        <el-table-column
          align="center"
          prop="type_name"
          label="文档类型">
        </el-table-column>
        <el-table-column
          align="center"
          label="申报所需文件">
          <template slot-scope="scope">
            <span>{{scope.row.need?'是':'否'}}</span>
          </template>
        </el-table-column>
        <el-table-column
          align="center"
          prop="task_name"
          label="所属任务">
        </el-table-column>
      </el-table>

    </div>
</template>

<script>
    export default {
        name: "documentView",
        props:{
            datas:{
                type:Object,
                default:function () {
                    return{member:[]}
                }
            }
        },
        watch:{
            datas:{
                handler:function(newV,oldV){
                    this.setData(newV);
                },
                deep:true,
                immediate:true,
            }
        },
        data(){
            return{
                list:[]
            }
        },
        methods:{
            setData:function (data) {
                this.findDocument(data.project_task)
            },
            findDocument:function (list) {

                for (let i = 0; i < list.length; i++){
                    if (list[i].files && list[i].files.length > 0){

                        list[i].files.forEach(item=>{
                            item.task_id = list[i].id;
                            item.task_name = list[i].task_name;
                        })
                        this.list = this.list.concat(list[i].files)
                    }
                    if (list[i].children && list[i].children.length > 0){
                        this.findDocument(list[i].children)
                    }
                }
            },
        }
    }
</script>

<style scoped>

</style>
